<?php
if (isset($_GET['type'])){
if ($_GET['type']=="register"){
$email=$_POST['email'];
$password=$_POST['password'];
$confirmpassword=$_POST['confirmpassword'];
$question=$_POST['question'];
$answer=$_POST['answer'];
$yanzheng=$_POST['yanzheng'];
$captcha=$_POST['captcha'];
$time=time();
$mysql = mysql_query("SELECT * FROM xige_user WHERE email='$email'");
$info=mysql_fetch_array($mysql);
if ($email=="" or $password=="" or $confirmpassword==""  or $question=="0"  or $answer==""  or $captcha==""){
echo "每一项每一空都必须填";
}elseif ($yanzheng!=$captcha){
echo "对不起您的验证码输入错误";
}elseif (!preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$/",$email)){
echo "请输入正确的电子邮箱";
}elseif ($password!=$confirmpassword){
echo "您两次密码输入不一致";
}elseif ($info['email']==$email) {
echo "这个邮箱已经在本站注册过了";
}else {
mysql_query("INSERT INTO xige_user (id,email,pass,question,answer,regdate,tip) VALUES ('','$email','$password','$question','$answer','$time','0')");
mysql_query("INSERT INTO xige_qiandao (id,email,common,continuous,commontime) VALUES ('','$email','0','0','0')");
mysql_query("INSERT INTO xige_info (id,email,qqnum,quota,spread,length,sidnew,batch,emailsend) VALUES ('','$email','0','5','0','0','0','0','0')");
$password=md5($password);
setcookie("Xige_User","$email",time()+3600);
setcookie("Xige_Pass","$password",time()+3600);
echo "注册成功!欢迎加入本站";
}

}elseif ($_GET['type']=="login"){
$email=$_POST['email'];
$password=$_POST['password'];

$mysql = mysql_query("SELECT * FROM xige_user WHERE email='$email'");
$info=mysql_fetch_array($mysql);

if ($email==""){
echo "登录邮箱不能为空";
jump(0,"",3);
}elseif ($password==""){
echo "登录密码不能为空";
jump(0,"",3);
}elseif ($info['email']==""){
echo '此帐号不存在请<a href="./register.php">注册</a>';
jump(1,"./register.php",3);
}elseif ($info['pass']!=$password){
echo "小伙伴们都惊呆了,登录密码居然错误";
jump(0,"",3);
}else{
echo "登录成功在跳转用户界面";
jump(1,"./user",0);
$password=md5($password);
setcookie("Xige_User","$email",time()+3600);
setcookie("Xige_Pass","$password",time()+3600);
}
}elseif ($_GET['type']=="logout"){
setcookie("Xige_User", "", time()-36000);
setcookie("Xige_Pass", "", time()-36000);
echo "小伙伴您退出成功~正在跳转首页";
jump(1,"./",0);
}elseif ($_GET['type']=="logints"){
echo "小伙伴~您还没登录,着急去用户界面干嘛?";
}elseif ($_GET['type']=="qiandao"){
$time=time();
$date=$info_qd['commontime'];
$time1=date("Y-m-d H:i:s",$time);
$date1=date("Y-m-d H:i:s",$date);
$dates=mktime(0,0,0,date("m",$date),date("d",$date),date("Y",$date));
$times=mktime(0,0,0,date("m",$time),date("d",$time),date("Y",$time));
$shicha=round(($times-$dates)/(3600*24),0);
$common=$info_qd['common']+1;
$continuous=$info_qd['continuous']+1;
if ($date=="0"){
mysql_query("UPDATE xige_qiandao SET common= '$common', continuous='$continuous', commontime='$time' WHERE email= '$cookieuser'");
echo "您是第一次签到哦!签到成功了!";
}elseif ($time1==$date1){
echo "您今天已经签到过了!请明天再来";
}elseif ($shicha<=1){
if ($continuous%3==0){
$quota=$userinfo['quota'] + 5 ;
mysql_query("update xige_info set quota='$quota' where email='$cookieuser' ");
mysql_query("UPDATE xige_qiandao SET common= '$common', continuous='$continuous', commontime='$time' WHERE email= '$cookieuser'");
echo "您已连续签到3天~~扩充5个挂Q配额";
}else{
mysql_query("UPDATE xige_qiandao SET common= '$common', continuous='$continuous', commontime='$time' WHERE email= '$cookieuser'");
echo "您已连续签到成功~~";
}
}else{
mysql_query("UPDATE xige_qiandao SET common= '$common', continuous='0', commontime='$time' WHERE email= '$cookieuser'");
echo "小伙伴!签到成功!";
}
}elseif ($_GET['type']=="del"){
if (isset($_POST['qid'])){
$qid=$_POST['qid'];
$qqnum=$userinfo['qqnum'] - count($qid);
foreach ($qid as $qid)
{
	$qqserverinfo = mysql_query("SELECT * FROM xige_qqlist WHERE qid='".$qid."' and email='$cookieuser'");
	$qqinfo = mysql_fetch_array($qqserverinfo);
	$qqserver=$qqinfo['fwq'];
	
	$mysql_userinfos = mysql_query("SELECT * FROM xige_info WHERE email='$cookieuser'");
	$userinfos=mysql_fetch_array($mysql_userinfos);
	
	$length=(time() - $qqinfo['adddate'])+$userinfos['length'];
	
	mysql_query("UPDATE xige_info SET length='$length' WHERE email='$cookieuser'");
	
	mysql_query("DELETE FROM xige_qqlist WHERE qid='$qid' and email='$cookieuser'");
	mysql_query("DELETE FROM xige_$qqserver WHERE qid='$qid' and email='$cookieuser'");
}
mysql_query("UPDATE xige_info SET qqnum='$qqnum' WHERE email='$cookieuser'");
echo "所选号码已删除";
}else{
echo "您还未选择QQ号码";
}
}elseif ($_GET['type']=="changepass"){
if ($_POST['password']==$userdata['pass']){
$passpass=$_POST['passpass'];
mysql_query("UPDATE xige_user SET pass='$passpass' WHERE email='$cookieuser'");
echo "密码修改成功!请重新登录";
}else{
echo "原密码错误!不能修改";
}
}else{
echo "您输入命令类型不存在哦";
}
}else{
echo "小伙伴节操何在?你别自己改网址额";
}
?>